package instrarbre;

import exprarbre.ASAExpr;
import java.util.HashMap;

public class ASADoWhile extends ASAInstr {

    private ASAExpr expression;
    private ASAInstr instruction;

    public ASADoWhile(ASAExpr expression, ASAInstr instruction) {
        this.expression = expression;
        this.instruction = instruction;
    }

    @Override
    public ASAInstr getInstr() {
        return instruction;
    }

    @Override
    public void interpreter(HashMap<String, Integer> affectation) {
        do {
            try {
                instruction.interpreter(affectation);
            }
            catch (BreakException e) {
                break;
            }
            catch (ContinueException e) {
                continue;
            }
        }
        while (expression.evalue(affectation) != 0);
    }
}
